<div class="fsh-pop">
    <div id="add_form" class="layui-form">
        <input type="password" style="display: none" />
        <input type="hidden"  value="2" name="type"/>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>账号</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" placeholder="请输入关键字" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>密码</label>
            <div class="layui-input-block">
                <input type="password" name="mima" lay-verify="pass" placeholder="请输入关键字" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="remima" lay-verify="pass|equal" placeholder="请输入关键字" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>姓名</label>
            <div class="layui-input-block">
                <input name="nickname" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="0" title="男" checked="">
                <input type="radio" name="sex" value="1" title="女">
            </div>
        </div>

<!--        <div class="layui-form-item layui-form-text">-->
<!--            <label class="layui-form-label"><i>*</i>职位</label>-->
<!--            <div class="layui-input-block">-->
<!--                <input name="job" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input">-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>电话</label>
            <div class="layui-input-block">
                <input name="phone" maxlength="20" placeholder="请输入内容" class="layui-input" lay-verify="phone|required">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>邮箱</label>
            <div class="layui-input-block">
                <input name="email" maxlength="20" placeholder="请输入内容" class="layui-input" lay-verify="email|required">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>所属学校</label>
            <div class="layui-input-block">
                <input type="hidden" name="school_id" id="schoolId">
                <input  placeholder="请输入内容" class="layui-input" lay-verify="required" readonly id="schoolName">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="upload_header">上传头像</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="demo1">
                        <p id="demoText"></p>
                        <input type="hidden" name="photo" id="photo"/>
                    </div>
                </div>
            </div>

        </div>
    </div>

</div>
<style type="text/css">
    #demo1 {
        width: 100px;
        height: 100px;
        border: 1px solid #e3e3e3;
    }
</style>
<script type="text/javascript">


    layui.use(['upload', 'form','table'], function () {
        var upload = layui.upload;
        var form = layui.form;
        var table = layui.table;
        // 选择学校
        $('#schoolName').click(function () {
            showBigDialog({
                title: '选择学校'
                , template: './views/school/class/template/school.html'
                , yes: function (index, layero) {
                    var checkData = table.checkStatus('schoolTable').data;
                    layer.close(index);
                    $('#schoolId').val(checkData[0].id);
                    $('#schoolName').val(checkData[0].schoolName);
                }

            })
        });
        //执行实例
        var uploadInst = upload.render({
            elem: '#upload_header'
            , url: context + '/api/fileupload/add'
            , field: 'attach'
            , done: function (res) {
                //如果上传失败
                if (res.success) {
                    $('#demo1').attr('src', res.link);
                    $('#photo').val(res.link);
                } else {
                    layui.layer.msg('上传失败');
                }
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });

    });

</script>
